﻿namespace MicroCloud.Utils
{
    /// <summary>
    /// 微云缓存服务功能接口
    /// </summary>
    public interface ICacheDataService
    {
        #region 同步
        /// <summary>
        /// 获取缓存
        /// </summary>
        /// <param name="Key">缓存键</param>
        CacheData Get(object Key);

        /// <summary>
        /// 获取缓存
        /// </summary>
        /// <param name="Group">缓存键</param>
        List<CacheData> GetByGroup(object Group);

        /// <summary>
        /// 获取缓存
        /// </summary>
        List<CacheData> GetAll();

        /// <summary>
        /// 设置缓存
        /// </summary>
        /// <param name="Key">缓存键</param>
        /// <param name="Value">缓存值</param>
        /// <param name="Type">缓存类型</param>
        /// <param name="Group">缓存分组</param>
        /// <param name="expiresUtc">过期时间UTC标准</param>
        void Set(object Key, object Value, object Type, object Group, DateTime? expiresUtc = null);

        /// <summary>
        /// 移除缓存
        /// </summary>
        /// <param name="Key">缓存键</param>
        void Remove(object Key);

        /// <summary>
        /// 移除缓存
        /// </summary>
        /// <param name="Group">缓存分组</param>
        void RemoveByGroup(object Group);

        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="Key">缓存键</param>
        bool IsExisted(object Key);

        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="Group">缓存分组</param>
        bool IsExistedByGroup(object Group);

        #endregion

        #region 异步
        /// <summary>
        /// 异步获取缓存
        /// </summary>
        /// <param name="Key">缓存键</param>
        Task<CacheData> GetAsync(object Key);

        /// <summary>
        /// 异步获取缓存
        /// </summary>
        /// <param name="Group">缓存键</param>
        Task<List<CacheData>> GetByGroupAsync(object Group);

        /// <summary>
        /// 异步获取缓存
        /// </summary>
        Task<List<CacheData>> GetAllAsync();

        /// <summary>
        /// 异步设置缓存
        /// </summary>
        /// <param name="Key">缓存键</param>
        /// <param name="Value">缓存值</param>
        /// <param name="Type">缓存类型</param>
        /// <param name="Group">缓存分组</param>
        /// <param name="expiresUtc">过期时间UTC标准</param>
        Task SetAsync(object Key, object Value, object Type, object Group, DateTime? expiresUtc = null);

        /// <summary>
        /// 异步移除缓存
        /// </summary>
        /// <param name="Key">缓存键</param>
        Task RemoveAsync(object Key);

        /// <summary>
        /// 异步移除缓存
        /// </summary>
        /// <param name="Group">缓存分组</param>
        Task RemoveByGroupAsync(object Group);

        /// <summary>
        /// 异步是否存在
        /// </summary>
        /// <param name="Key">缓存键</param>
        Task<bool> IsExistedAsync(object Key);

        /// <summary>
        /// 异步是否存在
        /// </summary>
        /// <param name="Group">缓存分组</param>
        Task<bool> IsExistedByGroupAsync(object Group);

        #endregion
    }
}